<template>
	<view class="">
		<button @click="fun1()">点击</button>
		<u-picker v-model="dataNum" :show="false" ref="uPicker" :columns="columns" @confirm="confirm" @change="changeHandler"></u-picker>
		<view class="">
			{{dataNum}}
		</view>
		<uni-card title="标题文字" thumbnail="" extra="额外信息" note="Tips">
			内容主体，可自定义内容及样式
		</uni-card>
		<view class="btn">
			<button @click="open">123</button>
		</view>
		<view class="">
			<!-- {{_userInfo}} -->
			<view class="iconfont icon-fangwuxinxi"></view>
			234
		</view>
		<button @click="funFun(dataNumber)">点击我保存token</button>
	</view>
</template>

<script>
	import context from '../../lib/java110/Java110Context.js';
	const constant = context.constant;
	export default {
		data() {
			return {
				dataNumber:"你好",
				TOKEN:"56re4g564er5gerg54",
				// userInfo: {},
				show: true,
				dataNum:'123',
				columns: [
					['南窑头小区', '家田国际小区'],
					['11栋','12栋','13栋','14栋','15栋','16栋','17栋','18栋'],
					['11单元', '12单元', '13单元', '14单元','15单元'],
					['1层', '2层']
				],
				columnData: [
					['11栋','12栋','13栋','14栋','15栋','16栋','17栋','18栋'],
					['21栋','22栋','23栋','24栋','25栋','26栋','27栋','28栋'],
					['1单元', '2单元', '3单元', '4单元']
				],
				columnCount:[
					['1单元', '2单元', '3单元', '4单元','5单元'],
					['1层', '2层']
				]
			}
		},
		methods: {
			funFun(dataNumber){
				uni.setStorage({
					key: 'storage_key',
					data: 'hello',
					success: function () {
						console.log('success');
					}
				});
			},
			open(){
				uni.navigateTo({
					url:'../openDoorByQrCode/openDoorByQrCode'
				})
			},
			fun1() {
				this.show = false
			},
			changeHandler(e) {
				const {
					columnIndex,
					columnDataIndex,
					columnCountIndex,
					value,
					values, // values为当前变化列的数组内容
					index,
					// 微信小程序无法将picker实例传出来，只能通过ref操作
					picker = this.$refs.uPicker
				} = e
				// 当第一列值发生变化时，变化第二列(后一列)对应的选项
				if (columnIndex === 0) {
					// picker为选择器this实例，变化第二列对应的选项
					picker.setColumnValues(1, this.columnData[index])
					this.columnDataIndex = this.columnData[index]
					if(columnDataIndex === 0){
						picker.setColumnValues(1, this.columnData[index].columnData[index])
						// if(columnCount === 0){
						// 	picker.setColumnValues(1, this.columnCount[index])
						// }
					}
				}
			},
			// 回调参数为包含columnIndex、value、values
			confirm(e) {
				this.dataNum =  e.value
				this.show = false
			},
			onLoad(options) {
				let _that = this;

				_that.userInfo = context.getUserInfo();
			},
		}
	}
</script>
<style>
	.btn{
		display: flex;
		justify-content: center;
		align-items: center;
		margin: auto;
		height: 70rpx;
		width: 400rpx;
		border-radius: 30rpx;
	}
</style>
